﻿Public Class frmHopDong

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim sql As String = "select * from HopDong"
        Dim DATA As New ketnoidulieu()
        dgvhopdong.DataSource = DATA.ExcuteDataTable(sql)
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim sql As String = "Insert into HopDong(MaHD, MaNhanVien,MaNha,NgayKiBatDau,NgayKetThuc,SoTien) values ('" & txtmahopdong.Text & "','" & txtmanhanvien.Text & "', '" & txtbatdau.Text & "','" & txtketthuc.Text & "','" & txtsotien.Text & "')"
        Dim INS As New ketnoidulieu()
        INS.SQL_ExecuteNonQuery(sql)
        Dim sl As String = "select * from HopDong"
        dgvhopdong.DataSource = INS.ExcuteDataTable(sl)
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If txtmahopdong.Text = "" Then
            MsgBox(" Bạn Phải Nhập Giá Trị Cấn Xóa MAHOPDONG !!! ")
        Else
            Dim sql As String = String.Format("delete * from HopDong where MaHD = '" & txtmahopdong.Text & "'")
            Dim KN As New ketnoidulieu()
            KN.SQL_ExecuteNonQuery(sql)
            Dim sl As String = "select * from HopDong"
            dgvhopdong.DataSource = KN.ExcuteDataTable(sl)
        End If
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        Dim sql As String = String.Format("Update Nha Set  MaNhanVien = '{0}', MaNha ='{1}',NgayKiBatDau='{2}',NgayKetThuc='{3}',SoTien='{4}' where MaHD = '" & txtmahopdong.Text & "'", txtmanhanvien.Text, txtmanha.Text, txtbatdau.Text, txtketthuc.Text, txtsotien.Text)
        Dim INS As New ketnoidulieu()
        INS.SQL_ExecuteNonQuery(sql)
        Dim sl As String = "select * from HopDong"
        dgvhopdong.DataSource = INS.ExcuteDataTable(sl)
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Dim sql As String = String.Format("select * from HopDong where  MaNhanVien='{0}' or MaNha='{1}' or MaHD='{2}'", txtmnv.Text, txtmn.Text, txtmhd.Text)
        Dim DATA As New ketnoidulieu()
        dgvhopdong.DataSource = DATA.ExcuteDataTable(sql)
    End Sub
End Class